﻿using DalatCooking.Core;
using DalatCooking.Core.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_DocumentDetail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Document n = DocumentManager.FindById(DocID);
        Page.Title = (n != null) ? n.Name : "Not found";
        lblTitle.Text = (n != null) ? n.Name + " #" + n.DocumentId : "Not found";
        lblBody.Text = (n != null) ? n.Body : "Not found";
        imgDoc.Src = "" + ((n != null) ? n.Picture : "/uploads/images/noimage.png");
        Course c = CourseManager.FindById(n.CourseId);

        lblCategoryName.Text = (c != null) ? c.Name : "Not found";
        pictureCate.Src = "" + ((c != null) ? c.Picture : "/uploads/images/noimage.png");
        lblDesc.Text = (c != null) ? c.Description : "Not found";
        
        rptOrther.DataSource = DocumentManager.FindAll().FindAll(t => t.CourseId == n.CourseId);
        rptOrther.DataBind();

    }
    public int DocID
    {
        get
        {
            if (Request.QueryString["DocID"] != null)
                return ConvertObject.ToInt(Server.HtmlEncode(Request.QueryString["DocID"]));
            return -1;
        }
    }
}